<!DOCTYPE html>
<html xml:lang="fr" lang="fr">
<head>
    
    <meta name="description" content="Gestion des bts sio">
    <meta name="author" content="nc">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > 
</head>
<?php
    if(isset($_POST["table"])) {$table = $_POST["table"];} else{$table = "";}
    if(isset($_POST["ligne"])) {$ligne = $_POST["ligne"];} else{$ligne = "";}

    require_once '../include/class.pdoSio.inc.php';
    
    if($table == "experience_prof") {
        if(isset($_POST["poste"])) {$poste = addslashes($_POST["poste"]);} else{$poste = "";}
        if(isset($_POST["anneeDebut"])) {$anneeDebut = $_POST["anneeDebut"];} else{$anneeDebut = "";}
        if(isset($_POST["anneeFin"])) {$anneeFin = $_POST["anneeFin"];} else{$anneeFin = "";}
        if(isset($_POST["fonction"])) {$fonction = addslashes($_POST["fonction"]);} else{$fonction = "";}
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteAction("UPDATE cv_experience_prof SET poste = '".$poste."', anneeDeb = ".$anneeDebut.", anneeFin = ".$anneeFin.", fonction = '".$fonction."' WHERE id_experience_prof = ".$ligne);
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_experience_prof WHERE id_experience_prof = ".$ligne);
    } elseif ($table == "formation") {
        if(isset($_POST["Diplome"])) {$diplome = addslashes($_POST["Diplome"]);} else{$diplome = "";}
        if(isset($_POST["AnneeDebut"])) {$AnneeDebut = $_POST["AnneeDebut"];} else{$AnneeDebut = "";}
        if(isset($_POST["AnneeFin"])) {$AnneeFin = $_POST["AnneeFin"];} else{$AnneeFin = "";}
        if(isset($_POST["Etab"])) {echo $etab = addslashes($_POST["Etab"]);} else{$etab = "";}
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteAction("UPDATE cv_formation SET Diplome = '".$diplome."', AnneeDeb = ".$AnneeDebut.", AnneeFin = ".$AnneeFin.", Etab = '".$etab."' WHERE id_formation = ".$ligne);
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_formation WHERE id_formation = ".$ligne);
    } elseif ($table == "informatique") {
        if(isset($_POST["competence"])) {$competence = addslashes($_POST["competence"]);} else{$competence = "";}
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteAction("UPDATE cv_informatique SET competence = '".$competence."' WHERE id_informatique = ".$ligne);
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_informatique WHERE id_informatique = ".$ligne);
    } elseif ($table == "interet") {
        if(isset($_POST["musique"])) {$musique = addslashes($_POST["musique"]);} else{$musique = "";}
        if(isset($_POST["sport"])) {$sport = addslashes($_POST["sport"]);} else{$sport = "";}
        if(isset($_POST["autre"])) {$autre = addslashes($_POST["autre"]);} else{$autre = "";}
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteAction("UPDATE cv_interet SET musique = '".$musique."', sport = '".$sport."', autre = '".$autre."' WHERE id_interet = ".$ligne);
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_interet WHERE id_interet = ".$ligne);
    } elseif ($table == "langue") {
        if(isset($_POST["langue"])) {$langue = addslashes($_POST["langue"]);} else{$langue = "";}
        if(isset($_POST["niveau"])) {$niveau = addslashes($_POST["niveau"]);} else{$niveau = "";}
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteAction("UPDATE cv_langue SET langue = '".$langue."', niveau = '".$niveau."' WHERE id_langue = ".$ligne);
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_langue WHERE id_langue = ".$ligne);
    } else {
        if(isset($_POST["photo"])) {$photo = addslashes($_POST["photo"]);} else{$photo = "";}
        if(isset($_FILES["photo"])) {$photo = addslashes($_FILES["photo"]);} else{$photo = "";}
        $pdo = PdoSio::getPdoSio();
        $image = file_get_contents($_FILES['photo']['tmp_name']);
        $etudiants = $pdo->requeteAction("UPDATE cv_photo SET photo = ".$photo." WHERE id_cv_photo = ".$ligne);
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_photo WHERE id_cv_photo = ".$ligne);
    }
    header("Location: ../index.php?uc=cv&action=visualiser&id=".$unEtudiant[0]['id_utilisateur']."&table=".$table);

